package com.example.admin.controller;

import com.example.admin.base.PageResponse;
import com.example.admin.base.ResponseResult;
import com.example.admin.bean.NursingProject;
import com.example.admin.service.NursingProjectservice;

import org.apache.ibatis.annotations.Delete;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/nursingproject")

public class NursingProjectcon {
    @Autowired
    NursingProjectservice nursingProjectservice;
    @GetMapping("list")

    public ResponseResult<Object> searchingforlist(@RequestParam(defaultValue = "1")Integer pagenum,
                                                  @RequestParam(defaultValue = "5") Integer pagesize,  NursingProject nursingProject){
        PageResponse<NursingProject> list = nursingProjectservice.searchingforlist(pagenum, pagesize, nursingProject);
        return ResponseResult.success(list);
    }
    @PostMapping("/save")

    public ResponseResult<Integer> save(@RequestBody NursingProject nursingProject){
        Integer num = nursingProjectservice.save(nursingProject);
        System.out.println("我进来了save");
        return ResponseResult.success(num);
    }
    @GetMapping("/findbyid")

    public ResponseResult<NursingProject> findbyid(Long id){
       NursingProject nursingProject = nursingProjectservice.findbyid(id);
        return ResponseResult.success(nursingProject);
    }
    @PutMapping("/edit")

    public ResponseResult<Integer> edit(@RequestBody NursingProject nursingProject){
        System.out.println("我进来了edit");
        Integer num = nursingProjectservice.edit(nursingProject);
        return ResponseResult.success(num);
    }
    @GetMapping("/fixstatus/{id}/{status}")

    public ResponseResult<Integer> fixstatus(@PathVariable("id")Long id,@PathVariable("status")Integer status){
       Integer successnum =  nursingProjectservice.fixstatus(id,status);
       return ResponseResult.success(successnum);
    }
    @DeleteMapping("/delete/{id}")

    public ResponseResult<Integer> delete(@PathVariable("id") Long id){
       Integer deletenum =  nursingProjectservice.delete(id);
       return ResponseResult.success(deletenum);
    }
}
